﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using System.Threading;
using KalenderTradisional;
using System.Diagnostics;

namespace KalenderTradisional
{
    public partial class UserControl1 : UserControl
    {
        private static int counter = 0;
        public Kalender kalender;
        public UserControl1()
        {
            InitializeComponent();
            DateTime tamp = System.DateTime.Now;
            kalender = new Kalender(tamp.Year, tamp.Month, tamp.Day);

            Debug.WriteLine(kalender.showJawa(tamp.Year, tamp.Month, tamp.Day));
            set();
        }

        public string calendarType = "Masehi";
        public enum jns { Masehi, Jawa, China };
        public jns calendar;

        public jns jnsCalendar
        {
            get
            {
                return calendar;
            }
            set
            {
                this.calendar = value;
                calendarType = value.ToString();
                show();
            }
        }

        private void set()
        {
                lblHari.Text = kalender.getHari();
                lblTanggal.Text = kalender.getTanggal();
                lblBulan.Text = kalender.getBulan();
                lblTahun.Text = kalender.getTahun();            
        }

                
        private void show()
        {
            if (calendarType.Equals("Masehi"))
            {
                kalender.setToMasehi();
                set();
                label1.Text = "MASEHI";
                this.BackgroundImage = Image.FromFile("img/backgroundmasehii.png", true);
            }
            else if (calendarType.Equals("Jawa"))
            {
                kalender.setToJawa();
                set();
                label1.Text = "JAWA";
                this.BackgroundImage = Image.FromFile("img/backgroundjawa.png", true);
            }
            else if (calendarType.Equals("China"))
            {
                kalender.setToChinese();
                set();
                label1.Text = "CHINA";
                this.BackgroundImage = Image.FromFile("img/backgroundchina.png", true);
            }
        }

        private void UserControl1_Load(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {

        }

        private void btnNext_Click(object sender, EventArgs e)
        {
            kalender.addHari(1);
            show();
        }

        private void btnPrev_Click(object sender, EventArgs e)
        {
            kalender.addHari(-1);
            show();
        }

        private void btnMthNxt_Click(object sender, EventArgs e)
        {
            kalender.addBulan(1);
            show();
        }

        private void btnMthPrv_Click(object sender, EventArgs e)
        {
            kalender.addBulan(-1);
            show();
        }

        private void btnYearNxt_Click(object sender, EventArgs e)
        {
            kalender.addTahun(1);
            show();
        }

        private void btnYearPrv_Click(object sender, EventArgs e)
        {
            kalender.addTahun(-1);
            show();
        }


        private void label1_Click_1(object sender, EventArgs e)
        {

        }

        private void lblTanggal_Click(object sender, EventArgs e)
        {

        }

        private void lblHari_Click(object sender, EventArgs e)
        {

        }
        
        /*
        private void GoTo_Click(object sender, EventArgs e)
        {
            int tgl = 0, bln = 0, thn = 0;
            string tamp = GoTo.Text;
            string[] words = tamp.Split(' ');
            int.TryParse(words[2], out thn);
            int.TryParse(words[1], out bln);
            int.TryParse(words[0], out tgl);            
            kalender.goTo(thn,bln,tgl);
            show();
        }
        */

        private void lblBulan_Click(object sender, EventArgs e)
        {

        }
    }
}


